/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.j2eem.service.common;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

/**
 *
 * @author wucy
 */
public class Download {

    public boolean downloadPicture(String urlString) {
        URL url = null;
        try {
            url = new URL(urlString);
            DataInputStream dataInputStream = new DataInputStream(url.openStream());
            byte[] buffer = new byte[1024];
            if (dataInputStream.read(buffer) > 0) {
                return true;
            }
            dataInputStream.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            return false;
        }
        return true;
    }
}
